﻿using System;

namespace KryptecizerBase.Decryption
{
    /// <summary>
    /// Abstract Decryptor class to deviate futher decryptors.
    /// </summary>
    public abstract class Decryptor
    {
        #region abstract methods

        /// <summary>
        /// Abstract decryption method.
        /// </summary>
        public abstract void Decrypt();
        #endregion

        #region protected methods

        /// <summary>
        /// Called when [decryption startet].
        /// </summary>
        protected void OnDecryptionStartet()
        {
            if (DecryptionStartet != null)
                DecryptionStartet();
        }

        /// <summary>
        /// Called when [decryption ended].
        /// </summary>
        /// <param name="successful">if set to <c>true</c> [successful].</param>
        protected void OnDecryptionEnded(bool successful)
        {
            if (DecryptionEnded != null)
                DecryptionEnded(successful);
        }

        /// <summary>
        /// Called when [decryption processing].
        /// </summary>
        /// <param name="percentDone">The percent done.</param>
        protected void OnDecryptionProcessing(int percentDone)
        {
            if (DecryptionProcessing != null)
                DecryptionProcessing(percentDone);
        }
        #endregion

        #region Events and Delegates
        /// <summary>
        /// Handles DecryptionStartet Event
        /// </summary>
        public delegate void DecryptionStartedEventHandler();
        /// <summary>
        /// Occurs when [decryption startet].
        /// </summary>
        public event DecryptionStartedEventHandler DecryptionStartet;

        /// <summary>
        /// Handles DecryptionProcessing Event.
        /// </summary>
        public delegate void DecryptionProcessingEventHandler(int percentDone);
        /// <summary>
        /// Occurs when [decryption processing].
        /// </summary>
        public event DecryptionProcessingEventHandler DecryptionProcessing;

        /// <summary>
        /// Handles DecryptionEnded Event.
        /// </summary>
        public delegate void DecryptionEndedEventHandler(bool successful);
        /// <summary>
        /// Occurs when [decryption ended].
        /// </summary>
        public event DecryptionEndedEventHandler DecryptionEnded;
        #endregion
    }
}
